Get just an IP address only from `ipconfig` using native windows command
NickName:user9013730 Ask DateTime:2018-03-09T16:26:26

Get just an IP address only from `ipconfig` using native windows command

Let say this is an output of Windows ipconfig command.

c:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.1.10
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

c:\>

In Linux OS, I can easily get just an IP Address using grep and cut command.

user@linux:~$ cat ip  
c:\>ipconfig

Windows IP Configuration

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.1.10
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1

c:\>
user@linux:~$ 

user@linux:~$ cat ip | grep IPv                 
   IPv4 Address. . . . . . . . . . . : 192.168.1.10
user@linux:~$ 

user@linux:~$ cat ip | grep IPv | cut -d ':' -f 2
 192.168.1.10
user@linux:~$ 

However, in Windows this is the best I can get using findstr command. Is there a way whereby we can cut just the IP portion out of this output?

c:\>ipconfig | findstr IPv4
   IPv4 Address. . . . . . . . . . . : 192.168.1.10

c:\>

What I'm expecting is something like this using native windows command only

c:\>ipconfig | <some command here just to get an IP Address only>
   192.168.1.10
c:\>

Copyright Notice:Content Author:「user9013730」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49189466/get-just-an-ip-address-only-from-ipconfig-using-native-windows-command

More about “Get just an IP address only from `ipconfig` using native windows command” related questions

Get just an IP address only from `ipconfig` using native windows command

Let say this is an output of Windows ipconfig command. c:\&gt;ipconfig Windows IP Configuration Wireless LAN adapter Wireless Network Connection: Connection-specific DNS Suffix . : IPv4

Show Detail

How to get just the bare IP 4 address from terminal in linux using the new ip command vs ipconfig?

ipconfig does not exist anymore as a command available in Ubuntu 20.04 and later I assume. The new command is just ip. When I run the ip address command I get the entire list of all devices and ip

Show Detail

Get IP address on Windows 7 via command line

I have a list of aliases defined in a command file (aliases.cmd) that I load whenver I run a command prompt (cmd.exe /k aliases.cmd). Using doskey, I have several aliases defined and I am trying to

Show Detail

Get ipconfig result with python in windows

I am new here and just learning python. I need help to get the right mac-address of my network card in windows using python. I tried to search, and found these : Python - Get mac address Getting MAC

Show Detail

ipconfig get first mac address

I am using this cmd command to get all the MAC addresses of the machine: ipconfig /all The problem is that it prints all the information and provides no switch to print just the mac. It also prints

Show Detail

How to get and store the localhost ip address into a variable (Windows 10)

In MacOs I used the below command to get the machine local ip address echo $(/usr/sbin/ipconfig getifaddr en0) I can also set this IP address into a variable like this as well export DISPLAY=$(/us...

Show Detail

If else batch command with ipconfig

I'm having trouble with using an if else statement in a batch command. I'm running Windows XP. I wrote a simple batch file to output my ip address which works fine. However, I would like to include...

Show Detail

Java program and ipconfig shows different IP address

Recently the IP address of my system as show by the ipconfig has changed from 10.2.200.76 to 10.2.200.75 but the IP address returned by the following java code InetAddress.getLocalHost().getHostAd...

Show Detail

Get DHCP Server address with only Powershell, like ipconfig /all

Get-NetIPConfiguration doesn't show DHCP server's ip address information. How can I do same as ipconfig /all but with PowerShell native tools?

Show Detail

Batch File - Get IP address

I have a problem with my Batch file. In my file, i want to get the IP address of my machine as a variable. Im running Windows Server 2003 R2 So, this is what i tried : for /f "tokens=1-2 delims...

Show Detail